using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using DTO;
using BUS;

namespace DEAN04
{
    public partial class DanhSachKhamBenh : Form
    {
        public int stt = 1;
        private void LoadData(List<BenhNhanDTO> lst)
        {
            dtgv_danhsachbenhnhan.Rows.Clear();
            stt = 1;
            for (int i = 0; i < lst.Count; i++)
            {
                string[] row = new string[] { stt++.ToString(), lst[i].HoTen, lst[i].GioiTinh, lst[i].NamSinh.ToString(), lst[i].DiaChi };
                dtgv_danhsachbenhnhan.Rows.Add(row);
            }
        }
        public DanhSachKhamBenh()
        {
            InitializeComponent();
        }

        private void DanSachKhamBenh_Load(object sender, EventArgs e)
        {
            List<PhieuKhamDTO> lst = PhieuKhamBUS.Select();
            List<BenhNhanDTO> bn = new List<BenhNhanDTO>();
            for (int i = 0; i < lst.Count; i++)
            
                if (lst[i].NgayKham.Day == tb_ngaykham.Value.Day &&
                    lst[i].NgayKham.Month == tb_ngaykham.Value.Month &&
                    lst[i].NgayKham.Year == tb_ngaykham.Value.Year)

                    bn.Add(BenhNhanBUS.SelectByID(lst[i].MaBenhNhan));
            LoadData(bn);            
        }
        private void tb_ngaykham_ValueChanged(object sender, EventArgs e)
        {
            List<PhieuKhamDTO> lst = PhieuKhamBUS.Select();
            List<BenhNhanDTO> bn = new List<BenhNhanDTO>();
            for (int i = 0; i < lst.Count; i++)
            
                if (lst[i].NgayKham.Day == tb_ngaykham.Value.Day &&
                    lst[i].NgayKham.Month == tb_ngaykham.Value.Month &&
                    lst[i].NgayKham.Year == tb_ngaykham.Value.Year)

                    bn.Add(BenhNhanBUS.SelectByID(lst[i].MaBenhNhan));
            LoadData(bn);   
        }

        private void bt_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}